package com.example.gfsquadwebviewproject.data;

import android.content.Context;
import android.util.Log;

import com.example.gfsquadwebviewproject.util.PreferencesUtils;

public class ConfigData {
    String TAG = "ConfigData";
    Context context;
    Constant constant;

    String url = null;
    String addr = null;
    String path = null;

    String password = null;//密码
    String schoolName = null;//校区
    String teachingBuildingName = null;//教学楼
    String classNumber = null;//课室
    String classId = null;//课室id

    String class_path;//课室配置路径


    public ConfigData(Context context) {
        this.context = context;
    }

    public String getUrl() {
        url = getAddr() + getPath();
        return url;
    }


    public String getAddr() {
        addr = PreferencesUtils.getString(context,PreferenceKey.ADDR_KEY,constant.addr);
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr;
        PreferencesUtils.putString(context,PreferenceKey.ADDR_KEY,addr);
    }

    public String getPath() {
        path = PreferencesUtils.getString(context,PreferenceKey.PATH_KEY,constant.path);
        return path;
    }

    public void setPath(String path) {
        this.path = path;
        PreferencesUtils.putString(context,PreferenceKey.PATH_KEY,path);
    }

    public String getClass_path() {
        String path = PreferencesUtils.getString(context,PreferenceKey.CLASS_PATH_KEY,constant.class_path);
        return path;
    }

    public void setClass_path(String class_path) {
        PreferencesUtils.putString(context,PreferenceKey.CLASS_PATH_KEY,class_path);
    }

    public String getPassword() {
        password = PreferencesUtils.getString(context,PreferenceKey.PASS_WORD_KEY,constant.defaultPassword);
        return password;
    }

    public void savePassword(String password) {
        this.password = password;
        PreferencesUtils.putString(context,PreferenceKey.PASS_WORD_KEY,password);
    }

    public String getSchoolName() {
        schoolName = PreferencesUtils.getString(context,PreferenceKey.SCHOOL_NAME);
        return schoolName;
    }

    public void saveSchoolName(String schoolName) {
        this.schoolName = schoolName;
        PreferencesUtils.putString(context,PreferenceKey.SCHOOL_NAME,schoolName);
    }

    public String getTeachingBuildingName() {
        teachingBuildingName = PreferencesUtils.getString(context,PreferenceKey.TEACHING_BUILDING);
        return teachingBuildingName;
    }

    public void saveTeachingBuildingName(String teachingBuildingName) {
        this.teachingBuildingName = teachingBuildingName;
        PreferencesUtils.putString(context,PreferenceKey.TEACHING_BUILDING,teachingBuildingName);
    }

    public String getClassNumber() {
        classNumber = PreferencesUtils.getString(context,PreferenceKey.CLASS_NUMBER,"");
        Log.d(TAG,"classNumber："+classNumber);
        return classNumber;
    }

    public void saveClassNumber(String classNumber) {
        this.classNumber = classNumber;
        PreferencesUtils.putString(context,PreferenceKey.CLASS_NUMBER,classNumber);
    }

    public String getClassId() {
        classId = PreferencesUtils.getString(context,PreferenceKey.CLASS_ID);
        Log.d(TAG,"classId："+classId);
        return classId;
    }

    public void saveClassId(String classId) {
        this.classId = classId;
        PreferencesUtils.putString(context,PreferenceKey.CLASS_ID,classId);
    }


    //Url地址+参数的字符串
    public String getUrl_Param(){
//        return (getUrl()+"&class_name="+getClassNumber().replace("-","")).trim();
        return "http://office.column.com.cn:9091//plug-in/ueditor_jsp/dialogs/selidshow/slideShow.html";
    }

}
